package com.lanou.bookstore.book.web.servlet;

import com.lanou.bookstore.book.domain.Book;
import com.lanou.bookstore.book.service.BookService;
import com.lanou.bookstore.book.service.BookServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/bds")
public class BookDetailsServlet extends HttpServlet {
    BookService cs = new BookServiceImpl();
    Book book = new Book();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String paraDetails = req.getParameter("paraDetails");
        List<Book> bookDetailsList = cs.queryByBid(paraDetails);
        for (Book book1 : bookDetailsList) {
            book = book1;
        }
        req.getSession().setAttribute("book", book);
        req.getRequestDispatcher("/jsps/book/desc.jsp").forward(req, resp);
    }


}
